home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performGeometryConstraint.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.6 KB  |  331 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  18 July 1997
  22. //
  23. //  Description:
  24. //        This script provides an option box dialog for the geometryConstraint command.
  25. //
  26. //    Input Arguments:
  27. //        boolean showOptionBox    true - show the option box dialog
  28. //                                false - just execute the command
  29. //
  30. //
  31. //  Procedure Name:
  32. //      setOptionVars
  33. //
  34. //  Description:
  35. //        Initialize the option values.
  36. //
  37. //  Input Arguments:
  38. //        Whether to set the options to default values.
  39. //
  40. //  Return Value:
  41. //      None.
  42. //
  43. proc setOptionVars(int $forceFactorySettings)
  44. {
  45.     //    weight
  46.     //
  47.     if ($forceFactorySettings || !`optionVar -exists geometryConstraintWeight`) {
  48.         optionVar -floatValue geometryConstraintWeight 1.0;
  49.     }
  50. }
  51.  
  52. //
  53. //  Procedure Name:
  54. //      geometryConstraintSetup
  55. //
  56. //  Description:
  57. //        Update the state of the option box UI to reflect the option values.
  58. //
  59. //  Input Arguments:
  60. //      parent               - Top level parent layout of the option box UI.
  61. //                             Required so that UI object names can be 
  62. //                             successfully resolved.
  63. //
  64. //        forceFactorySettings - Whether the option values should be set to
  65. //                             default values.
  66. //
  67. //  Return Value:
  68. //      None.
  69. //
  70. global proc geometryConstraintSetup(string $parent, int $forceFactorySettings)
  71. {
  72.     //    Retrieve the option settings
  73.     //
  74.     setOptionVars($forceFactorySettings);
  75.  
  76.     setParent $parent;
  77.  
  78.     //    Query the optionVar's and set the values into the controls.
  79.  
  80.     //    weight
  81.     //
  82.     floatSliderGrp -edit 
  83.         -value `optionVar -query geometryConstraintWeight`
  84.         geometryConstraintWeight;
  85.  
  86. }
  87.  
  88. //
  89. //  Procedure Name:
  90. //      geometryConstraintCallback
  91. //
  92. //  Description:
  93. //        Update the option values with the current state of the option box UI.
  94. //
  95. //  Input Arguments:
  96. //      parent - Top level parent layout of the option box UI.  Required so
  97. //               that UI object names can be successfully resolved.
  98. //
  99. //        doIt   - Whether the command should execute.
  100. //
  101. //  Return Value:
  102. //      None.
  103. //
  104. global proc geometryConstraintCallback(string $parent, int $doIt)
  105. {
  106.     setParent $parent;
  107.  
  108.     //    Set the optionVar's from the control values, and then
  109.     //    perform the command.
  110.  
  111.     //    weight
  112.     //
  113.     optionVar -floatValue geometryConstraintWeight
  114.         `floatSliderGrp -query -value geometryConstraintWeight`;
  115.  
  116.     if ($doIt) {
  117.         performGeometryConstraint 0; 
  118.         addToRecentCommandQueue "performGeometryConstraint 0" "GeometryConstraint";
  119.     }
  120. }
  121.  
  122. //
  123. //  Procedure Name:
  124. //     geometryConstraintOptions
  125. //
  126. //  Description:
  127. //        Construct the option box UI.  Involves accessing the standard option
  128. //        box and customizing the UI accordingly.
  129. //
  130. //  Input Arguments:
  131. //      None.
  132. //
  133. //  Return Value:
  134. //      None.
  135. //
  136. proc geometryConstraintOptions()
  137. {
  138.     //    Name of the command for this option box.
  139.     //
  140.     string $commandName = "geometryConstraint";
  141.  
  142.     //    Build the option box actions.
  143.     //
  144.     string $callback = ($commandName + "Callback");
  145.     string $setup = ($commandName + "Setup");
  146.  
  147.     //    Get the option box.
  148.     //
  149.     string $layout = getOptionBox();
  150.     setParent $layout;
  151.     
  152.     //    Pass the command name to the option box.
  153.     //
  154.     setOptionBoxCommandName($commandName);
  155.     
  156.     //    Activate the default UI template.
  157.     //
  158.     setUITemplate -pushTemplate DefaultTemplate;
  159.  
  160.     //    Turn on the wait cursor.
  161.     //
  162.     waitCursor -state 1;
  163.  
  164.     tabLayout -scr true -tv false;
  165.     string $parent = `columnLayout -adjustableColumn 1`;
  166.     
  167.     floatSliderGrp -label "Weight"
  168.         -field true -min 0.0 -max 10.0 
  169.         geometryConstraintWeight;
  170.  
  171.     //    Turn off the wait cursor.
  172.     //
  173.     waitCursor -state 0;
  174.     
  175.     //    Deactivate the default UI template.
  176.     //
  177.     setUITemplate -popTemplate;
  178.  
  179.     //    'Apply' button.
  180.     //
  181.     string $applyBtn = getOptionBoxApplyBtn();
  182.     button -edit
  183.         -label "Add"
  184.         -command ($callback + " " + $parent + " " + 1)
  185.         $applyBtn;
  186.  
  187.     //    'Save' button.
  188.     //
  189.     string $saveBtn = getOptionBoxSaveBtn();
  190.     button -edit 
  191.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  192.         $saveBtn;
  193.  
  194.     //    'Reset' button.
  195.     //
  196.     string $resetBtn = getOptionBoxResetBtn();
  197.     button -edit 
  198.         -command ($setup + " " + $parent + " " + 1)
  199.         $resetBtn;
  200.  
  201.     //    Set the option box title.
  202.     //
  203.     setOptionBoxTitle("Geometry Constraint Options");
  204.  
  205.     //    Step 8: Customize the 'Help' menu item text.
  206.     //    ============================================
  207.     //
  208.     setOptionBoxHelpTag( "Geometry" );
  209.  
  210.     //    Set the current values of the option box.
  211.     //
  212.     eval (($setup + " " + $parent + " " + 0));    
  213.     
  214.     //    Show the option box.
  215.     //
  216.     showOptionBox();
  217. }
  218.  
  219. //
  220. //  Procedure Name:
  221. //      geometryConstraintHelp
  222. //
  223. //  Description:
  224. //        Return a short description about this command.
  225. //
  226. //  Input Arguments:
  227. //      None.
  228. //
  229. //  Return Value:
  230. //      string.
  231. //
  232. proc string geometryConstraintHelp()
  233. {
  234.     // ******** Example
  235.     // "  Command: Extrude - create a surface using extrusion.\n" +
  236.     // "Selection: curves and isoparms."
  237.  
  238.     return 
  239.     "  Command: geometryConstraint - constrain one object to lie on surface of another\n" +
  240.     "Selection: One or more transforms or shapes followed by a transform";    
  241. }
  242.  
  243. //
  244. //  Procedure Name:
  245. //      assembleCmd
  246. //
  247. //  Description:
  248. //        Construct the command that will apply the option box values.
  249. //
  250. //  Input Arguments:
  251. //      None.
  252. //
  253. //  Return Value:
  254. //      None.
  255. //
  256. proc string assembleCmd()
  257. {
  258.     string $cmd = "geometryConstraint";
  259.  
  260.     setOptionVars(false);
  261.  
  262.     $cmd = ($cmd 
  263.             + " -weight " + `optionVar -query geometryConstraintWeight`);
  264.  
  265.     return $cmd;
  266. }
  267.  
  268. //
  269. //  Procedure Name:
  270. //      performGeometryConstraint
  271. //
  272. //  Description:
  273. //        Perform the geometryConstraint command using the corresponding 
  274. //        option values.  This procedure will also show the option box
  275. //        window if necessary as well as construct the command string
  276. //        that will invoke the geometryConstraint command with the current
  277. //        option box values.
  278. //
  279. //  Input Arguments:
  280. //      0 - Execute the command.
  281. //      1 - Show the option box dialog.
  282. //      2 - Return the command.
  283. //
  284. //  Return Value:
  285. //      None.
  286. //
  287. global proc string performGeometryConstraint(int $action)
  288. {
  289.     string $cmd = "";
  290.  
  291.     switch ($action) {
  292.  
  293.         //    Execute the command.
  294.         //
  295.         case 0:
  296.             //    Retrieve the option settings
  297.             //
  298.             setOptionVars(false);
  299.  
  300.             //    Get the command.
  301.             //
  302.             $cmd = `assembleCmd`;
  303.  
  304.             //    Execute the command with the option settings.
  305.             //
  306.             evalEcho($cmd);
  307.  
  308.             break;
  309.  
  310.         //    Show the option box.
  311.         //
  312.         case 1:
  313.             geometryConstraintOptions;
  314.             break;
  315.  
  316.         //    Return the command string.
  317.         //
  318.         case 2:
  319.             //    Retrieve the option settings.
  320.             //
  321.             setOptionVars (false);
  322.  
  323.             //    Get the command.
  324.             //
  325.             $cmd = `assembleCmd`;
  326.             break;
  327.     }
  328.     return $cmd;
  329. }
  330.  
  331.